package com.mvc.web.common.page;


public class Page {
	
	private int PAGE_SIZE;
	private int currentPage;
	private int totalPage;
	private int totalCount;
	
	private int minPage;
	private int maxPage;
	private int nextPage;
	private int prePage =1;
	private int startNum;
	
	public Page(){
		
	}
	
	public Page(int totalCount,int currentPage,int PAGE_SIZE){
		this.totalCount = totalCount;//数据总数
		this.currentPage = currentPage;//当前页
		this.PAGE_SIZE = PAGE_SIZE;//页面显示数据条数
		startNum = (currentPage - 1) * PAGE_SIZE;
		totalPage = (totalCount + PAGE_SIZE-1)/PAGE_SIZE > 0 ? (totalCount + PAGE_SIZE-1)/PAGE_SIZE : 1;
		if(currentPage > 1){
			prePage = currentPage -1;//上一页
		}
		nextPage = currentPage+1;
		if(nextPage > totalPage ){
			nextPage = (totalPage >0 ? totalPage : 1);
		}
		if(totalPage <= 5){
			minPage = 1;
			maxPage = totalPage;
		}else{
			minPage = currentPage-2;
			maxPage = currentPage+2;
			
			if(minPage < 1){
				minPage = 1;
				maxPage = 5;
			}
			if(maxPage > totalPage){
				maxPage = totalPage;
				minPage = maxPage - 4;
			}
		}
		
	}

	
	
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public void setMinPage(int minPage) {
		this.minPage = minPage;
	}

	public void setMaxPage(int maxPage) {
		this.maxPage = maxPage;
	}

	public int getNextPage() {
		return nextPage;
	}

	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}

	public int getPrePage() {
		return prePage;
	}

	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public int getMinPage() {
		return minPage;
	}

	public int getMaxPage() {
		return maxPage;
	}

	public int getStartNum() {
		return startNum;
	}

	public void setStartNum(int startNum) {
		this.startNum = startNum;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	
	public  int getPageSize() {
		return PAGE_SIZE;
	}

}
